package com.dotstone.chipism.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.dotstone.chipism.R;
import com.dotstone.chipism.bean.HttpURL;

public class StoreFragment extends Fragment {
	public static StoreFragment instance;
	private WebView webview;

	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		instance = this;
		View view = inflater.inflate(R.layout.fragment_shop, container, false);
		findView(view);
		return view;
	}

	private void findView(View view) {
		// TODO Auto-generated method stub
		webview = (WebView) view.findViewById(R.id.webview);
		//
		webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
		// 支持javascript
		webview.getSettings().setJavaScriptEnabled(true);
		// 设置可以支持缩放
		webview.getSettings().setSupportZoom(true);
		// 设置出现缩放工具
		webview.getSettings().setBuiltInZoomControls(true);
		// 扩大比例的缩放
		webview.getSettings().setUseWideViewPort(true);
		// 自适应屏幕
		webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
		webview.getSettings().setLoadWithOverviewMode(true);
		webview.setWebViewClient(new WebViewClient());
		webview.getSettings().setLoadWithOverviewMode(true);
	}

	@Override
	public void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		webview.loadUrl(HttpURL.SHOP);
		Log.i("wmy", "HttpURL.SHOP+shopToken = " + HttpURL.SHOP);
	}
}
